//
//  CZMainControllerViewController.m
//  notification-test
//
//  Created by Song on 2018/6/19.
//  Copyright © 2018年 Song. All rights reserved.
//

#import "CZMainControllerViewController.h"

#define GSYNAME @"updateLoginInfo"

@interface CZMainControllerViewController ()
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;
@property (weak, nonatomic) IBOutlet UIButton *enterBtn;
- (IBAction)enterBtn:(id)sender;

@end

@implementation CZMainControllerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 按钮圆角
    self.enterBtn.layer.cornerRadius = 5;
    self.enterBtn.clipsToBounds = YES;
}

// 点击登录按钮 （跳转 + 添加监听器）
- (IBAction)enterBtn:(id)sender {
    [self addObserverToNotificationMethod];
}

// 添加监听器的方法
-(void)addObserverToNotificationMethod {
    // 注册监听器
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateLoginInfo:) name:GSYNAME object:nil];
}

-(void)updateLoginInfo:(NSNotification *)notification {
//    NSDictionary *userInfo = notification.userInfo;
    self.infoLabel.text = notification.userInfo[@"loginInfo"];
}
@end
